package com.apes.fn.fico.reimbursement.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.framework.util.ApesConst;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 费用还款明细
 * Created by lishikun on 2021/2/1 17:17
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ExpenseRepaymentItem.CONST_TABLE_NAME)
public class ExpenseRepaymentItem extends BaseModel {
    public static final String CONST_TABLE_NAME = "fn_expense_repayment_item";

    @Id
    @Column(name = "id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "费用还款明细", padding = 8)
    @Comment("费用借支明细编码")
    private String id;

    @Comment("来源单据")
    @Column(name = "source", length = 30)
    private String source;

    @Comment("来源单据类型")
    @Column(name = "source_business_type", length = 32)
    private String sourceBusinessType;

    @Comment("还款金额")
    @Column(name = "repayment_money", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    private double repaymentMoney = 0.0d;

    @ManyToOne(optional = false)
    @JoinColumn(name = "expense_debit_id", referencedColumnName = "id")
    @Comment("费用借支")
    private ExpenseDebit expenseDebit;

    @Comment("备注")
    @Column(name = "remark")
    private String remark;

    @States(name = "状态", values = {
            @State(id = "sent", name = "制单"),
            @State(id = "approve", name = "审核"),
            @State(id = "delete", name = "删除"),
            @State(id = "done", name = "完成")
    })
    @Column(name = "state", length = 10)
    private String state;
}
